package controladores;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import beans.GuiaBean;

public class GuiaDataModel extends ListDataModel<GuiaBean> implements SelectableDataModel<GuiaBean> {    
		  
	    public GuiaDataModel() {  
	    }  
	  
	    public GuiaDataModel(List<GuiaBean> lstGuia) {  
	        super(lstGuia);  
	    }  
	      
	    @Override  
	    public GuiaBean getRowData(String rowKey) {  
	        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data  
	          
	        List<GuiaBean> lstGuia = (List<GuiaBean>) getWrappedData();  
	          
	        for(GuiaBean objGuiaBean : lstGuia) {  
	            if(objGuiaBean.getsItem().equals(rowKey))  
	                return objGuiaBean;  
	        }  
	        return null;  
	    }  
	  
	    @Override  
	    public Object getRowKey(GuiaBean objGuiaBean) {  
	        return objGuiaBean.getsItem();  
	    }  
}
